home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PRINTER / EPSON.ARJ / PRNFILTR.ASM < prev    next >
Assembly Source File  |  1987-04-16  |  8KB  |  300 lines

  1. ;
  2. ;    Printer Filter - will watch for print sequences and convert
  3. ;             them into new sequences
  4. ;
  5. ;    Setup so that an NEC P5XL will more closely emulate an Epson
  6. ;    FX-80 or JX-80.  Note that a P5XL is Epson LQ compatible
  7. ;
  8. ;    This program installs itself as a TSR and monitors int 17h which
  9. ;    is the bios printer support. If the requested operation is an
  10. ;    output byte for printer LPT1, the program is activated.
  11. ;
  12. ;    The printer control codes are intercepted as follows:
  13. ;
  14. ;        ESC % (select ROM/Downloaded Character set) is ignored.
  15. ;
  16. ;        ESC & (define download character set) is ignored.
  17. ;
  18. ;        ESC m (can not remember why I did this - had a program
  19. ;            that required it) is ignored.
  20. ;
  21. ;        ESC A (set line spacing in n/72nds of an inch) - converted
  22. ;            to setting in n/180ths of an inch by using the
  23. ;            formula n * 5 / 2.
  24. ;
  25. ;        ESC 3 (set line spacing in n/216ths of an inch) - converted
  26. ;            to setting in n/180ths of an inch by using the
  27. ;            formula n * 5 / 6.
  28. ;
  29. ;    For both the spacing setting conversions, they can not be exact in
  30. ;    all cases. If n is odd in ESC A, the error is 1/360th of an inch
  31. ;    per line. In the ESC 3 case, the max error is 5/1080 of an inch per
  32. ;    line - .306 in per 66 lines.
  33. ;
  34. ;    If you really have an NEC P5 and are sure of what is being sent
  35. ;    to it, the following changes will make the emulation more exact:
  36. ;
  37. ;        Change the labeled lines as shown here
  38. ;
  39. ;        esca:    mov    esc_seq,1
  40. ;
  41. ;        esc3:    mov    esc_seq,3
  42. ;
  43. ;        out_cd:    mov    al,1ch            ;get FS
  44. ;
  45. ;    This uses an P5 mode to output in 360ths of an inch but is limited
  46. ;    to a max line spacing of 255/360 (approx .711 in). This should be
  47. ;    okay for most graphics related software - but I had one package
  48. ;    (SAMNA Word III) that was trying to set spacing to 1 inch and had
  49. ;    problems.  For ESC A, the result is exact. For ESC 3, the possible
  50. ;    error is reduced to a max of 2/1080 of an inch per line or .122 in.
  51. ;
  52. ;    Installation
  53. ;
  54. ;    Assemble and create com file as follows: (you can use the copy
  55. ;        of prnfiltr.com with this archive if no changes are needed).
  56. ;
  57. ;        masm prnfiltr;
  58. ;        link prnfiltr;
  59. ;        exe2bin prnfiltr
  60. ;        del prnfiltr.exe
  61. ;        ren prnfiltr.bin prnfiltr.com
  62. ;
  63. ;    Add prnfiltr as a line in your autoexec.bat file
  64. ;
  65. ;    Comments
  66. ;
  67. ;    This program produced by:
  68. ;
  69. ;        Tom Frank
  70. ;        6474 Skyward Ct.
  71. ;        Columbia, Md 21045
  72. ;
  73. ;    I can be reached on either of these two local BBS systems.
  74. ;
  75. ;        Computer Connection (202) 547-2008
  76. ;        Baltimore Washington PC Exchange (301) 381-6411
  77. ;    or
  78. ;        Compuserve 73200,1162.
  79. ;
  80. ;    Comments or enhancements are welcome.  I wrote this originally
  81. ;    so that my P5XL would work properly with several graphics /
  82. ;    word processors which did not support it directly.  As always,
  83. ;    use at your own risk.
  84. ;
  85. code_seg    segment
  86.         assume    cs:code_seg, ds:code_seg
  87.  
  88.         org    100h
  89.  
  90. first:        jmp    load_it
  91.  
  92. ;    data storage
  93.  
  94. esc_seq        db    0            ;non-zero if doing replacement
  95. last_esc    db    0            ;non-zero if last char was ESC
  96. skip_cnt    dw    0            ;non-zero-count of chars to ignore
  97. lc_set        db    0            ;non-zero if in download char set command
  98. dwn_c1        db    0            ;1st char in download sequence
  99. five        db    5            ;for mpy
  100. twelve        db    0Ch            ;for mpy
  101.  
  102. ;    symbolic equates
  103.  
  104. old_int        equ    60h
  105.  
  106. routine        proc    far
  107.  
  108.         push    ds
  109.         push    cs
  110.         pop    ds
  111.  
  112.         cmp    dl,0            ;lpt 1?
  113.         jne    std_int            ;no-do std code
  114.  
  115.         cmp    ah,0            ;output byte function?
  116.         jne    std_int            ;no
  117.  
  118.         test    lc_set,0ffh        ;in download?
  119.         jz    go_on_1            ;no
  120.         jmp    download        ;yes
  121. go_on_1:    test    skip_cnt,0ffh        ;skipping chars?
  122.         jz    go_on_2            ;no
  123.         jmp    skip_chars        ;yes        
  124. go_on_2:    test    esc_seq,0ffh        ;doing an esc sequence?
  125.         jnz    do_seq            ;yes
  126.  
  127.         test    last_esc,0ffh        ;last char an escape?
  128.         jz    see_esc            ;no - see if this one is
  129.  
  130. ;    last char was an escape - is this something we need to do?
  131.  
  132.         mov    last_esc,0        ;reset escape seen flag
  133.         cmp    al,41h            ;is the char 'A'?
  134.         je    esca            ;yes
  135.         cmp    al,33h            ;is it '3'?
  136.         je    esc3            ;yes
  137.         cmp    al,6Dh            ;is the char 'm'?
  138.         je    escm            ;yes
  139.         cmp    al,26h            ;is the char '&'
  140.         je    esc_and            ;yes
  141.         cmp    al,25h            ;is the char '%'?
  142.         je    esc_perc
  143.  
  144. ;    not a sequence we change - output an escape and then this char
  145.  
  146.         push    ax
  147.         mov    al,1bh            ;get an escape
  148.         int    old_int
  149.         mov    dx,0
  150.         pop    ax
  151.         int    old_int
  152.  
  153. leave:        pop    ds
  154.         iret
  155.  
  156. std_int:    int    old_int
  157.         jmp    leave
  158.  
  159. see_esc:    cmp    al,1bh            ;is char ESC?
  160.         je    see_esc1        ;yes
  161.         jmp    chk_csub        ;no-check for char substitution
  162. see_esc1:    mov    last_esc,0ffh        ;yes-set flag
  163.         jmp    leave
  164.  
  165. esca:        mov    esc_seq,2        ;get divisor-set flag
  166.         jmp    leave
  167.  
  168. esc3:        mov    esc_seq,6
  169.         jmp    leave
  170.  
  171. escm:        mov    esc_seq,0ffh
  172.         jmp    leave
  173.  
  174. esc_and:    mov    lc_set,1        ;set saying just starting
  175.         jmp    leave
  176.  
  177. esc_perc:    mov    skip_cnt,2        ;skip next 2 chars
  178.         jmp    leave
  179.  
  180. do_seq:        push    ax            ;save argumet to sequence
  181.         mov    al,esc_seq        ;get sequence code
  182.         cmp    al,0ffh            ;special one to skip?
  183.         je    skip_it            ;yes
  184. out_cd:        mov    al,1bh            ;get ESC
  185.         int    old_int
  186.         mov    dx,0
  187.         mov    ah,0
  188.         mov    al,33h            ;get '3'
  189.         int    old_int
  190.         pop    ax            ;get arg back
  191.         mul    five            ;times multiplier
  192.         div    esc_seq            ;divide by argument
  193.                         ;result is in 180ths of an inch
  194.         mov    dx,0
  195.         mov    ah,0
  196.         int    old_int
  197.         mov    esc_seq,0
  198.         jmp    leave
  199.  
  200. skip_it:    pop    ax
  201.         mov    esc_seq,0
  202.         jmp    leave
  203.  
  204. skip_chars:    dec    skip_cnt        ;reduce count by 1
  205.         jmp    leave
  206.  
  207. download:    cmp    lc_set,1        ;only seen ESC & so far?
  208.         jne    down_1            ;no-seen more
  209.         mov    lc_set,2        ;yes-prepare for 1st char id
  210.         jmp    leave
  211. down_1:        cmp    lc_set,2        ;is this the 1st char?
  212.         jne    down_2            ;no
  213.         mov    dwn_c1,al        ;yes-save it
  214.         mov    lc_set,3        ;say looking for 2nd char
  215.         jmp    leave
  216. down_2:        sub    al,dwn_c1        ;get #chars to define
  217.         inc    al            ;normalize it
  218.         mul    twelve            ;times chars to skip
  219.         mov    skip_cnt,ax        ;save as chars to skip
  220.         mov    lc_set,0        ;clear download seq flag
  221.         jmp    leave
  222.  
  223. chk_csub:    cmp    al,7Fh
  224.         ja    chk_1            ;jump if user defined
  225.         jmp    std_int            ;no-just output it
  226. chk_1:        cmp    al,0B2h            ;do we want to sub it?
  227.         jne    chk_2            ;no
  228.         mov    al,0DAh
  229.         jmp    std_int
  230. chk_2:        cmp    al,0B5h            ;do we want to sub it?
  231.         jne    chk_3            ;no
  232.         mov    al,0C4h
  233.         jmp    std_int
  234. chk_3:        cmp    al,0B0h            ;do we want to sub it?
  235.         jne    chk_4            ;no
  236.         mov    al,0C0h
  237.         jmp    std_int
  238. chk_4:        cmp    al,0B1h            ;do we want to sub it?
  239.         jne    chk_5            ;no
  240.         mov    al,0B3h
  241.         jmp    std_int
  242. chk_5:        cmp    al,0B4h            ;do we want to sub it?
  243.         jne    chk_6            ;no
  244.         mov    al,0D9h
  245.         jmp    std_int
  246. chk_6:        cmp    al,0B7h            ;do we want to sub it?
  247.         jne    chk_7            ;no
  248.         mov    al,0BFh
  249.         jmp    std_int
  250. chk_7:        cmp    al,0B3h            ;do we want to sub it?
  251.         jne    chk_8            ;no
  252.         mov    al,0C3h
  253.         jmp    std_int
  254. chk_8:        cmp    al,0B6h            ;do we want to sub it?
  255.         jne    chk_9            ;no
  256.         mov    al,0C1h
  257.         jmp    std_int
  258. chk_9:        cmp    al,0B8h            ;do we want to sub it?
  259.         jne    chk_A            ;no
  260.         mov    al,0B4h
  261.         jmp    std_int
  262. chk_A:        cmp    al,0B9h            ;do we want to sub it?
  263.         jne    chk_B            ;no
  264.         mov    al,0C2h
  265.         jmp    std_int
  266. chk_B:        cmp    al,0BAh            ;do we want to sub it?
  267.         jne    chk_C            ;no
  268.         mov    al,0C5h
  269.         jmp    std_int
  270. chk_C:        jmp    std_int
  271.  
  272. routine        endp
  273.  
  274. load_it        proc    near
  275.         mov    ah,35h            ;get int vector
  276.         mov    al,17h            ;bios printer spt
  277.         int    21h
  278.         push    es
  279.         pop    ds            ;get segment
  280.         mov    dx,bx            ;get offset
  281.         mov    ah,25h            ;set int vector
  282.         mov    al,old_int        ;for old as this one
  283.         int    21h
  284.  
  285.         push    cs
  286.         pop    ds            ;get our address
  287.         mov    dx,offset routine
  288.         mov    ah,25h
  289.         mov    al,17h
  290.         int    21h
  291.  
  292.         mov    dx,offset load_it
  293.         int    27h
  294.  
  295. load_it        endp
  296.  
  297. code_seg    ends
  298.  
  299.         end    first
  300.